<?php
require "home/model/Model.php";
	class IndexModel extends Model{
		function __Construct(){
		parent::__Construct();
	}
	function getList(){
		
		$sql = "select * from foods";
		$data = $this->conn->query($sql);

		return $data;
	}
	function getListall($tid){
		$sql = "select * from foods where tid=$tid";
		$data=$this->conn->query($sql);
		return $data;
	}
	function getContent($vid){
		$sql = "select * from foods where vid=$vid";
		$data=$this->conn->query($sql);
		return $data;
	}
	function addUser($data,$file){
		$newname = $this->uploadfile($file);//调用uploadfile方法，得到newname

        $uname=$data['username'];
        $password=$data['password'];
        $gender=$data['gender'];
        $birthdate=$data['birthdate'];
        $hobby=implode($data['hobby'],',');
        $degree=$data['degree'];
        $intro=$data['intro'];
        $pic=$newname;
        $sql="insert into users VALUES ('null','$uname',md5('$password'),'$gender','$birthdate','$hobby','$degree','$intro','$pic')";
        $result=$this->conn->query($sql);
        return $result;
    }
    	function dologin(){
			session_start();
			$uname=$_POST["uname"];
			$password=$_POST["password"];
   			$sql = "select * from users where uname='$uname'and password='$password'";
   			$result=$this->conn->query($sql);
    		/*$result = mysql_query($sql, $conn);
    		$test = mysql_fetch_array($result);
			$row=mysql_fetch_assoc($result);*/
			  return $result;
    	
		}
		function search($data){
			$foodname=$data['foodname'];
			$sql="select * from foods WHERE foodname='$foodname'";
			$result=$this->conn->query($sql);
			return $result;

		}

}
?>